Param
(
    [Parameter(Mandatory=$true)]
    $PathList
)


function Reset-ItemDate()
{
    Param
    (
        [Parameter(Mandatory=$true)]
        $ObjectToreset
    )

    Write-Host "Updating `"$ObjectToreset`""

    $date = get-date
    
    try
    {
        Set-ItemProperty -Path $ObjectToreset -Name CreationTime -Value $date -ErrorAction Stop -ErrorVariable err
        Set-ItemProperty -Path $ObjectToreset -Name LastAccessTime -Value $date -ErrorAction Stop -ErrorVariable err
        Set-ItemProperty -Path $ObjectToreset -Name LastWriteTime -Value $date -ErrorAction Stop -ErrorVariable err
        Write-Host "Date successfully updated" -ForegroundColor Green
    }
    catch
    {
        Write-Host "Error while updating date: $err" -ForegroundColor Red
    }
    
    Write-Host ""        
}

function Reset()
{
    Param
    (
        [string[]]$ObjectsToreset
    )

    if($ObjectsToreset -eq $null)
    {
        Write-Host "Nothing to reset"
    }
    
    

    foreach($ObjectToreset in $ObjectsToreset)
    {
        Reset-ItemDate -ObjectToreset $ObjectToreset
        

        $Items = Get-ChildItem -Path $ObjectToreset -Recurse

        foreach($Item in $Items)
        {
            Reset-ItemDate -ObjectToreset $($Item.FullName)
        }
    }    
}


Reset -ObjectsToreset $PathList
